﻿<%@ Page Language="C#" MasterPageFile="~/admin/MasterPage.master" AutoEventWireup="true"
    CodeFile="GabaritoCad.aspx.cs" Inherits="admin_GabaritoCad" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
        function SelecionaChk() {
            var count = -1;
            var NomeForm = document.getElementById("aspnetForm");
            var hf = document.getElementById('<%= hfSelecionados.ClientID%>');
            hf.value = "";

            for (i = 0; i < NomeForm.elements.length; i++) {
                if (NomeForm.elements[i].type == "checkbox") {
                    if (NomeForm.elements[i].name.indexOf("ckbComponente") != -1) {
                        count++;
                        if (NomeForm.elements[i].checked) {
                            hf.value += count.toString() + ";";
                        }
                    }
                }
            }
        }
    </script>
    <div class="titulo">
        <asp:Label ID="lblTitulo" runat="server" Text="Gabarito"></asp:Label>
    </div>
    <br />
    <div class="grid">
        <div class="campos">
            <div class="coluna_titulo">
                <asp:Label ID="Label1" runat="server" Text="Processo:"></asp:Label>
            </div>
            <div class="coluna_texto">
                <asp:DropDownList ID="cod_processo_pro" AppendDataBoundItems="true" DataSourceID="odsProcesso"
                    DataTextField="descricao" DataValueField="cod_processo_pro" runat="server" EnableViewState="false"
                    Width="200px">
                    <asp:ListItem Value="-1">Selecione</asp:ListItem>
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Selecione o Processo!"
                    ControlToValidate="cod_processo_pro" Display="Dynamic" InitialValue="-1">*</asp:RequiredFieldValidator>
                <asp:ObjectDataSource ID="odsProcesso" TypeName="ProcessoSeletivo.DAO.Processo" SelectMethod="ListarProcessoTipo"
                    runat="server"></asp:ObjectDataSource>
            </div>
            <div class="clear">
            </div>
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div class="campos">
                    <div class="coluna_titulo">
                        <asp:Label ID="Label2" runat="server" Text="Qtd de questões:"></asp:Label>
                    </div>
                    <div class="coluna_texto">
                        <asp:TextBox ID="qtd_linhas" runat="server" Width="120px" onkeypress="return keypressNumero(event)"></asp:TextBox>
                        <asp:Button ID="btnAdicionar" runat="server" SkinID="btnLinha" Text="Adicionar" OnClick="btnAdicionar_Click"
                            CausesValidation="false" />
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <br />
                <asp:GridView ID="grvPrincipal" runat="server" OnRowDataBound="grvPrincipal_RowDataBound"
                    Width="280px" DataKeyNames="cod_questao_que">
                    <Columns>
                        <asp:TemplateField HeaderText="Nº da questão">
                            <HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" />
                            <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
                            <ItemTemplate>
                                <asp:TextBox ID="num_questao_que" runat="server" MaxLength="3" Width="80px" onkeypress="return keypressNumero(event)"
                                    onpaste="return false;"></asp:TextBox><asp:RequiredFieldValidator ID="rfvQuestao" runat="server"
                                        ControlToValidate="num_questao_que" Display="Dynamic" ErrorMessage="Preencha o número da questão!"
                                        SetFocusOnError="True">*</asp:RequiredFieldValidator>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Letra">
                            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Top" />
                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
                            <ItemTemplate>
                                <asp:DropDownList ID="des_letra_que" runat="server">
                                    <asp:ListItem Value="-1">Selecione</asp:ListItem>
                                    <asp:ListItem>A</asp:ListItem>
                                    <asp:ListItem>B</asp:ListItem>
                                    <asp:ListItem>C</asp:ListItem>
                                    <asp:ListItem>D</asp:ListItem>
                                    <asp:ListItem>E</asp:ListItem>
                                    <asp:ListItem Value="?">Nulo</asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="rfvLetra" runat="server" ControlToValidate="des_letra_que"
                                    Display="Dynamic" ErrorMessage="Informe a Letra da questão!" SetFocusOnError="True"
                                    InitialValue="-1">*</asp:RequiredFieldValidator>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Tipo de questão">
                            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Top" />
                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
                            <ItemTemplate>
                                <asp:DropDownList ID="tip_questao_que" runat="server">
                                    <asp:ListItem Value="O">Outros</asp:ListItem>
                                    <asp:ListItem Value="I">Inglês</asp:ListItem>
                                    <asp:ListItem Value="E">Espanhol</asp:ListItem>
                                </asp:DropDownList>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" Width="15px" />
                            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Top" Width="15px" />
                            <HeaderTemplate>
                                <asp:CheckBox ID="checkHeader" runat="server" onclick="javascript:CheckUnCheck(this);SelecionaChk();" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="ckbComponente" runat="server" onclick="javascript:CheckChild();SelecionaChk();" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        Nenhuma registro foi gerado!
                    </EmptyDataTemplate>
                </asp:GridView>
                <br />
                <div class="botoes">
                    <asp:Button ID="btnRemover" runat="server" SkinID="btnLinha" Text="Remover as questões selecionadas"
                        OnClick="btnRemover_Click" CausesValidation="False" OnClientClick="return confirm('Confirma Remoção?')" />
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnAdicionar" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnRemover" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:HiddenField ID="hfSelecionados" runat="server" />
        <div class="button">
            <asp:Button ID="btnSalvar" runat="server" Text="Salvar" OnClick="btnSalvar_Click" />
            <asp:Button ID="btnVoltar" runat="server" Text="Voltar" PostBackUrl="~/admin/Gabarito.aspx"
                CausesValidation="false" />
        </div>
    </div>
</asp:Content>
